Forum:Parser functions
"Parser functions" have been implemented and put to use on Wikipedia. Basically, these parser functions a little programming constructs that allow pages to be displayed in different ways based on the value of some parameters. For example, a sidebar template could be constructed so that lines for "unknown" values are automatically hidden, instead of either having to create several templates with different parameters, or having to live with a sidebar that has "unknown" written all over it. I already talked to the Wikia staff, and they would make these functions available on MA if we want to use them. Generally, I think that this is a good idea, but there's some potential for misuse - personally, I think that these functions should be restricted to templates as described above, but not be used on content pages for some of the more esoteric purposes that would be possible. Would anyone object to making that a policy? -- Cid Highwind 10:35, 22 April 2006 (UTC) :It's a good idea so long as it doesn't get out of control - we want to maintain uniform style. So yes, go ahead and make a policy on it. Jaz talk 18:36, 22 April 2006 (UTC) ::I guess that would be okay. I'm not entirely sure I understand it all, but then I'm an idiot, so... yeah. Anyways, so long as we have measures to prevent misuse, I'd say go for it. --From Andoria with Love 19:25, 22 April 2006 (UTC) :::For what I understand, that would make the (in)famous episode sidebar template possible :-). Don't think that enforcing a correct usage will give much trouble, as long as we have one. -- Rcog 22:07, 22 April 2006 (UTC) OK, a short example of these parser functions here. On the suggested starship sidebar template, there's a parameter for the registry number. Right now, when using the template, we have to give the parameter some value, otherwise it would appear as Registry: }. So, if the registry is unknown, we have to add that as a string and end up with a sidebar with (probably several) empty fields. With parser functions, we can check if a parameter was used at all (or alternatively, check if a parameter value was given as "unknown") and in that case omit the whole line in the sidebar. Possible misuse in this case would be, IMO, to check all parameters in this way. Some values should always be included in a given template, and if they are unknown the template shouldn't be used at all. Another form of misuse would be to use this function to add dozens of parameters to a template that would only be used in very rare special cases. Other available parser functions could be misused even further. I don't want to go into detail here, but there is, for example, a function that evaluates mathematical expressions (=does calculations) - which, I think, could do more harm than good. -- Cid Highwind 08:41, 24 April 2006 (UTC) ::::If there are to much ways to misuse these parser functions you should first ask yourself what the benefits might be when you start using them. Personally I have no idea what advantage these functions would have on the average user. -- Q 19:04, 25 April 2006 (UTC) I guess there are many wiki functions the "average user" doesn't care for, or doesn't even know they exist - that doesn't mean that those function can't be an advantage for a "power user", or even the project itself. As for the benefit of this function, let's go back to an existing example: Have a look at Template:Sidebar starship and its talk page. One point that has been discussed is the launch date, which is known only for very few ships. Without parser functions, we can either include a field for the launch date (which would then be "unknown" for most ships), or not include a field (while omitting the information in those cases where it is known), or create two different templates. With parser functions, we can make that field "optional" - it will only appear on the sidebar if it has a useful content. Similarly, the "registry" field could be made optional: not only do we not know the registry for many Starfleet starships, we could even use the same template for all ships, including alien starships, if we just removed that field. On the other hand, one could now have the idea to include everything into that template as an optional field. Some starship sidebars have "armament", some have "crew complement", some have "tonnage", etc. In the end, we would end up with a nearly unmaintainable template that serves no purpose, because it doesn't lead to any standardization - and that's what I would like to prevent. -- Cid Highwind 19:52, 25 April 2006 (UTC) ::::Well I am just an "average user" :) Your clarification helped and I can see its advantages aka forcing a uniform look-and-feel (like you said on the talk page). Could a user still add some extra text within the sidebar if he or she wanted to ? (I assume that with this form of sidebar only declared fields are visible, if they are filled that is) -- Q 20:43, 25 April 2006 (UTC) No, the sidebar would then have a relatively fixed content. Some fields would be mandatory, some would be optional, but unless we include some sort of "free text field" where a user can determine content and title (which I would call template misuse), there would be no way to include extra text. This is not a restriction of parser functions, however, but typical behaviour of a template - and as Kobi stated on the talk page of that template, we probably don't even want to have all information included in a sidebar. I think a sidebar should only be used for the most basic facts, not for everything that one is just too lazy to properly add to the main text. -- Cid Highwind 07:41, 26 April 2006 (UTC)